package com.owen.spring.cloud.seata.at.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.owen.spring.cloud.seata.at.entity.StorageTbl;
import com.owen.spring.cloud.seata.at.entity.feign.AccountTbl;
import com.owen.spring.cloud.seata.at.mapper.StorageTblMapper;
import com.owen.spring.cloud.seata.at.service.StorageTblService;
import com.owen.spring.cloud.seata.at.service.feign.CommonFeign;
import com.owen.spring.cloud.seata.at.service.feign.CustomerFeign;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StorageTblServiceImpl extends ServiceImpl<StorageTblMapper, StorageTbl> implements StorageTblService {

    @Autowired
    private CommonFeign commonFeign;

    @Autowired
    private CustomerFeign customerFeign;

    @Override
    @GlobalTransactional
    public boolean save(StorageTbl entity) {
        boolean result = super.save(entity);
        AccountTbl accountTbl = new AccountTbl();
        accountTbl.setMoney(10);
        accountTbl.setUserId("userId");
//        commonFeign.save(accountTbl);
        customerFeign.save(accountTbl);
        return result;
    }
}
